package com.probox.common.entity.domain.order;

import java.util.Date;
import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.probox.common.core.enums.CardServiceTypeEnum;
import com.probox.common.core.utils.StringUtils;
import com.probox.common.core.utils.money.PriceFormatUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.*;
import com.probox.common.core.annotation.Excel;

/**
 * 购物车明细对象 order_shop_cart
 *
 * @author hds
 * @date 2021-05-28
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("order_shop_cart")
public class OrderShopCart implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    //默认主键自增
    @TableId(value = "CART_UID", type = IdType.AUTO)
    private Long cartUid;
    /**
     * 平台ID
     */
    private Long platformUid;
    /**
     * 供应商ID
     */
    @Excel(name = "供应商ID")
    private Long supplierUid;
    /**
     * 商品ID
     */
    private Long proUid;

    @Excel(name = "商品类型")
    private String proType;

    public String getProTypeFmt(){
        return CardServiceTypeEnum.getNameByKey(proType);
    }

    /**
     * 商品名称
     */
    @Excel(name = "商品名称")
    private String proName;
    /**
     * 商品封面图
     */
    @Excel(name = "商品封面图")
    private String proImgUrl;

    @Excel(name = "商品编号")
    @ApiModelProperty(value = "商品编号")
    private String proNo;

    @Excel(name = "商品单位")
    @ApiModelProperty(value = "商品单位")
    private String proUnit;

    /**
     * 商品 SKU ID
     */
    private Long skuUid;
    /**
     * SKU图片
     */
    @Excel(name = "SKU图片")
    private String skuImgUrl;
    /**
     * SKU 描述
     */
    @Excel(name = "SKU 描述")
    private String skuDesc;
    /**
     * 价格
     */
    @Excel(name = "价格")
    private Long price;
    /**
     * 展示价格
     */
    @Excel(name = "展示价格")
    private Long showPrice;
    /**
     * 供应商价格
     */
    @Excel(name = "供应商价格")
    private Long supplierPrice;

    /**
     * 数量
     */
    @Excel(name = "数量")
    private Long cartNumber;
    /**
     * 合计金额
     */
    @Excel(name = "合计金额")
    private Long cartAmount;
    /**
     * 积分
     */
    @Excel(name = "积分")
    private Long score;

    /**
     * 标签
     */
    private String proTag;


    public Long getTotalScore(){
        if (score == null) return 0L;
        return cartNumber*score;
    }

    /**
     * 状态
     */
    @Excel(name = "状态")
    private String cartStatus;
    /**
     * 活动ID
     */
    @Excel(name = "活动ID")
    private Long activityUid;
    /**
     * 活动类型
     */
    @Excel(name = "活动类型")
    private String activityType;
    /**
     * 活动产品ID
     */
    @Excel(name = "活动产品ID")
    private Long activityProUid;

    /**
     * 是否显示在购物车
     */
    private String isShowInCart;
    /**
     * 创建人
     */
    @Excel(name = "创建人")
    private Long createUid;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 更新人
     */
    private Long updateUid;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 创建人名称
     */
    @Excel(name="创建人名称")
    private String createName;
    /**
     * 更新人名称
     */
    private String updateName;

    @TableField(exist = false)
    private List<String> createTimeArray;


    public String getPriceStr(){
        return PriceFormatUtil.format(price);
    }

    public String getShowPriceStr(){
        return PriceFormatUtil.format(showPrice);
    }

    public String getCartAmountStr(){
        return PriceFormatUtil.format(cartAmount);
    }

    public String getProImgUrlOne() {
        if(!StringUtils.isEmpty(proImgUrl)){
            String[] split = proImgUrl.split(",");
            return split[0];
        }
        return "";
    }

    @Excel(name="门店ID")
    private Long  storeId;

    @Excel(name="是否叠叠乐")
    private String isDdl;

    public String getSkuImgUrlOne() {
        if(!StringUtils.isEmpty(skuImgUrl)){
            String[] split = skuImgUrl.split(",");
            return split[0];
        }
        return "";
    }

    @TableField(exist = false)
    //是否支持金币支付
    private boolean useBoluoGoldCoin;
    //是否支持银币支付
    @TableField(exist = false)
    private boolean useBoluosilverCoin;
    //是否支持优惠券
    @TableField(exist = false)
    private boolean useCoupon;
    //是否支持会员折扣
    @TableField(exist = false)
    private boolean useMemberDiscount;
    //享受折扣的会员级别
    @TableField(exist = false)
    private Long discountMemberLevel;

}
